﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for BouquetDAL
/// </summary>
public class BouquetDAL
{
    DataAccess db = new DataAccess();
	public BouquetDAL()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    internal DataTable getBouquetByHome()
    {
        return db.executeSelect("getBoutquetByHome");
    }

    internal DataTable getAllBouquet()
    {
        return db.executeSelect("getAllBouquet");
    }



    internal bool updateStatusBouquet(string id)
    {
        SqlParameter[] paraList = new SqlParameter[1];
        paraList[0] = new SqlParameter("@B_ID", SqlDbType.NVarChar, 50);
        paraList[0].Value = id;
        int check = db.executeModifier("UpdateStatusBouquet", paraList);
        if (check > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    internal bool insertBouquet(string id, string name, float price, string details, string image, int cid)
    {
        SqlParameter[] paraList = new SqlParameter[6];
        paraList[0] = new SqlParameter("@B_ID", SqlDbType.NVarChar, 50);
        paraList[0].Value = id;
        paraList[1] = new SqlParameter("@B_Name", SqlDbType.NVarChar, 200);
        paraList[1].Value = name;
        paraList[2] = new SqlParameter("@B_Price", SqlDbType.Float);
        paraList[2].Value = price;
        paraList[3] = new SqlParameter("@B_Details", SqlDbType.NVarChar, 4000);
        paraList[3].Value = details;
        paraList[4] = new SqlParameter("@B_Image", SqlDbType.NVarChar, 4000);
        paraList[4].Value = image;
        paraList[5] = new SqlParameter("@C_ID", SqlDbType.Int);
        paraList[5].Value = cid;
        int check = db.executeModifier("InsertBouquet", paraList);
        if (check > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    internal DataTable getBouquetByID(string id)
    {
        SqlParameter[] paraList = new SqlParameter[1];
        paraList[0] = new SqlParameter("@B_ID", SqlDbType.NVarChar, 50);
        paraList[0].Value = id;
        return db.executeSelect("getBouquetByID", paraList);
    }

    internal bool updateBouquet(string id, string name, float price, string details, string image, int cid, int home)
    {
        SqlParameter[] paraList = new SqlParameter[7];
        paraList[0] = new SqlParameter("@B_ID", SqlDbType.NVarChar, 50);
        paraList[0].Value = id;
        paraList[1] = new SqlParameter("@B_Name", SqlDbType.NVarChar, 200);
        paraList[1].Value = name;
        paraList[2] = new SqlParameter("@B_Price", SqlDbType.Float);
        paraList[2].Value = price;
        paraList[3] = new SqlParameter("@B_Details", SqlDbType.NVarChar, 4000);
        paraList[3].Value = details;
        paraList[4] = new SqlParameter("@B_Image", SqlDbType.NVarChar, 4000);
        paraList[4].Value = image;
        paraList[5] = new SqlParameter("@C_ID", SqlDbType.Int);
        paraList[5].Value = cid;
        paraList[6] = new SqlParameter("@B_Home", SqlDbType.Int);
        paraList[6].Value = home;
        int check = db.executeModifier("UpdateBouquet",paraList);
        if (check > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}